namespace FictionsDownload.Migrations
{
    using FictionsDownload.DAL;
    using FictionsDownload.Model;
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Data.SQLite.EF6.Migrations;
    using System.Linq;
    internal sealed class ConfigurationSQLite : DbMigrationsConfiguration<db_SQLite>
    {
        public ConfigurationSQLite()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
            SetSqlGenerator("System.Data.SQLite", new SQLiteMigrationSqlGenerator());
        }

        protected override void Seed(db_SQLite context)
        {
            if(!context.Folders.Where(m=>m.FolderId == FolderModel.BaseNode).Any())
            {
                db_Init.GetFolders().ForEach(c => context.Folders.Add(c));
                db_Init.GetWebFormats().ForEach(c => context.WebFormats.Add(c));
                context.SaveChanges();
            }
        }
    }
}
